package renthouse.sever;/*
 * @创建者：黄苟苟
 * @创建时间：2021/5/19   9:59
 * @Description描述
 **/

import renthouse.dao.AdminDao;
import renthouse.dao.LandlordDao;
import renthouse.dao.UserDao;
import renthouse.entry.Admin;
import renthouse.entry.Landlord;
import renthouse.entry.User;
import renthouse.view.sever.LoginFrame;
;import java.util.List;

public class LoGinSever {
    /*房东的登录信息*/
    public boolean login_landlord(String loginnameVal, String passwordVal) {
        LandlordDao landlordDao = new LandlordDao();
        Landlord landlord = new Landlord();
        landlord.setLoginname(loginnameVal);
        landlord.setPassword(passwordVal);
        List <Landlord> list = landlordDao.query(landlord);
        if (list == null || list.size() == 0) {
            return false;
        } else {
            LoginFrame.loginlandlord = list.get(0);
            return true;
        }
    }

    /*房客的登陆信息*/
    public boolean login_user(String loginnameVal, String passwordVal) {
        UserDao userDao = new UserDao();
        User user = new User();
        user.setLoginname(loginnameVal);
        user.setPassword(passwordVal);
        List <User> list = userDao.query(user);
        if (list == null || list.size() == 0) {
            return false;
        } else {
            LoginFrame.loginuser = list.get(0);
            return true;
        }
    }
/*管理员的相关登录信息*/
    public boolean login_admin(String loginnameVal, String passwordVal) {
        AdminDao adminDao = new AdminDao();
        Admin admin = new Admin();
        admin.setLoginname(loginnameVal);
        admin.setPassword(passwordVal);
        List <Admin> list = adminDao.query(admin);
        if (list == null || list.size() == 0) {
            return false;
        } else {
            LoginFrame.loginadmin = list.get(0);
            return true;
        }
    }
}
